package com.bdqn.controller;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * 第一个Spring MVC控制器
 */
@Controller
@RequestMapping(value="/hello")
public class HelloController{ //  extends AbstractController
    /**
     * 重写父类方法
     */
//    @Override
//    protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
//        System.out.println("Spring MVC框架搭建成功！");
//        return new ModelAndView("hello");
//    }

    @RequestMapping(value="/hello1")
    public String hello1() throws Exception {
        System.out.println("Spring MVC框架搭建成功！");
        // 跳转到hello页面
        return "hello";
    }

    Logger logger = Logger.getLogger(HelloController.class);

    @RequestMapping(value="/hello2")
    public String hello2() throws Exception {
        logger.info("我的第一个Spring MVC程序，运行成功！");
        // 跳转到hello页面
        return "hello";
    }

    @RequestMapping(value="/hello3")
    public String hello3() throws Exception {
        logger.info("hello控制器下的另一个接口！");
        // 跳转到hello页面
        return "hello";
    }

    @RequestMapping(value="/hello4")
    public String hello4(@RequestParam(value = "readName", required = false) String realName) throws Exception {
        logger.info("你好" + realName + "欢迎来到Spring MVC框架！");
        // 跳转到hello.jsp页面
        return "hello";
    }

    @RequestMapping(value="/hello5")
    public String hello5(@RequestParam(value = "readName", required = false) String realName) throws Exception {
        logger.info("你好" + realName + "欢迎来到Spring MVC框架！");
        // 跳转到hello页面
        return "hello";
    }

}
